<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - <?php echo (C("INTENDANT_NAME")); ?> - by HemaCMS</title>
    <link href="/Public/intendant/css/admin_style.css" rel="stylesheet" />
    <script src="/Public/common/js/jquery.js"></script>
    <script src="/Public/common/js/jquery.cookie.js"></script>
    <script src="/Public/common/js/jquery.validate.min.js"></script> <!--表单验证-->
    <script src="/Public/common/js/colorPicker/colorPicker.js"></script>
    <link rel="stylesheet" href="/Public/common/js/colorPicker/style.css" />
    <script src="/Public/common/js/layer/layer.js"></script>
    <script src="/Public/intendant/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
    <link href="/Public/intendant/css/iteny.css" rel="stylesheet">

<script type="text/javascript">
    var catid = "21";
</script>
<style type="text/css">
.table-full .textbox ,.table-full .textbox .textbox-text{border-radius: 0;}
.table-full input.input_cxcolor{border-radius: 0;border: 0;}
.table-full table {
    table-layout: fixed;
    border-collapse: collapse;
    border-spacing: 0;
}
.table-full tr{background: #f8f8f8 url("/Public/intendant/images/table_border.png") repeat-x scroll 0 bottom;}
.table-full th {
    background-color: #f8f8f8 url("/Public/intendant/images/table_border.png") repeat-x scroll 0 bottom;
    border-right: 1px solid #e5e3e3;
    font-weight: 100;
    line-height: 24px;
    padding: 7px 10px 9px;
    text-indent: 10px;
    vertical-align: top;
}

.table-full td {
    color: #666;
    padding: 7px 10px 9px 15px;
    vertical-align: top;
}
.table_list{margin-bottom: 0;float: none;}
.table_right{
    float: right;
    width: 260px;
    overflow: hidden;
    margin-left: 10px;
}
.table_left{
    overflow: hidden;
    _zoom: 1;
    _float: left;
    margin-bottom: 100px;
}
.must_red {
    font-family: Simsun;
    color: #ff0000;
    margin-top: 3px;
    margin-left: -13px;
    position: absolute;
    font-size: 14px;
}
.table_list tr:hover th{
	color:white;
	background-color:#f9f9f9;
	background: #4d7690;
}

.table_list tr:hover td{
	color:black;
}
.btn_wrap .btn_wrap_pd {
    padding: 10px 20px 10px;
    background: #eaeaea ;
    border-top: 1px solid #d8d8d8;
  }
.layui-layer-dialog .layui-layer-content{
	background-color: #fafafa;
}
</style>
<!-- 图片上传开始 -->
<script type="text/javascript">
	var uploadImgUrl = '<?php echo U("Content/articleImg");?>';
	var delImgUrl = '<?php echo U("Content/delArticleImg");?>';
</script>
<link rel="stylesheet" type="text/css" href="/Public/common/js/webuploader/webuploader.css" />
<link rel="stylesheet" type="text/css" href="/Public/common/js/webuploader/style.content.css" />
<script type="text/javascript" src="/Public/common/js/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="/Public/common/js/webuploader/upload.content.js"></script>
<style type="text/css">
.webuploader-pick {padding: 10px 77px;background: #337ab7 none repeat scroll 0 0;border: 1px solid #2e6da4; }
.webuploader-pick-hover{background: #286090 none repeat scroll 0 0;border: 1px solid #204d74;}
</style>
<script type="text/javascript">
$(function(){

});
</script>
<!-- 图片上传结束 -->
<!-- <script type="text/javascript">
	$('#color_select').cxColor(); //颜色选择器

	var NyxxShowAddModule = {
	propertygrid: '#content-article-add-propertygrid',
	editorIframe: 'content-article-add-editor',

	//记录当前选项的位置，失去焦点的时候可以用来定位
	onClickRow: function(index){
		NyxxLeftShowModule.data = {id: '#content-article-add-propertygrid', index: index, field: 'value'};
	},

	//保存
	"wenzhang" : function(dom)
		type = $(dom).attr("method");
		url = $(dom).attr("action");
		data = $(dom).serialize();
		$.ajax({
			type: type,
			url: url,
			data: data,
			dataType:"json",
			beforeSend: function(){
				$.messager.progress({text:'处理中，请稍候...'});
			},
			success: function(data){
				$.messager.progress("close");
				if(!data.status){
					$.xf.alert('提示信息', data.info,'error');
				} else {
					$.xf.alert('提示信息', data.info,'info');
					// $($.xf.dialog_1).dialog('close');
					NyxxShowAddModule.back();
				}
			},
			error: function(data){
				$.messager.progress("close");
				$.xf.alert('提示信息', data.responseText,'error');
			}
		});
	},
	//返回栏目列表
	back: function(){
		var title = '<<?php echo ($title); ?>>';
		NyxxLeftShowModule.open(1, <<?php echo ((isset($catid) && ($catid !== ""))?($catid):0); ?>>,title);
	}
};
</script> -->

</head>
<body class="J_scroll_fixed" style="padding:8px;">
<form name="addArticle" action="<?php echo U('Content/addArticle');?>" method="post">
	<input type="hidden" name="addArticle" value="addArticle" />
	<input type="hidden" name="catid" value="<?php echo ($catid); ?>" />
	<div class="table_list" style="margin-bottom: 10px;">
		<div class="h_a">信息发布</div>
	</div>
	<div class="table_list table_right">
		<div class="art-right" title="编辑属性" >
			<div class="table-full">
				<table width="100%">
					<tbody>
						<tr>
							<td style="padding-top: 10px;font-weight: bold;font-size: 14px;">封面图片</td>
						</tr>
						<tr>
							<td style="padding-top: 10px;">
								<div id="uploader">
								    <!--用来存放item-->
								    <div id="contentbtn" title="文件必须在100KB以内">选择图片</div>
								    <div id="fileList" class="uploader-list"></div>
								</div>
							</td>
						</tr>
						<tr>
				          	<td><b>相关文章</b></td>
				        </tr>
				        <tr>
					        <td><input type="hidden" name="relation" id="relation" value="" style="50">
								<ul class="list-dot" id="relation_text">
								</ul>
								<a class="btn" id="relat" title="添加内容">添加相关文章</a>
								<span class="edit_content">
					  			<input type="button" value="显示已有" onclick="show_relation(1,0)" class="btn">
								</span><span></span>
							</td>
					    </tr>
						<tr>
				          	<td><b>内容页模板</b></td>
				        </tr>
				        <tr>
				            <td><select name="template" id="template"><option value="" selected="">默认模板</option><option value="">自定义</option></select><span></span></td>
				        </tr>
						<tr>
							<td style="padding-top: 10px;font-weight: bold;font-size: 14px;">是否显示</td>
						</tr>
						<tr>
							<td style="padding-top: 10px;">
								<input name="isshow" type='radio' id="isshow1" value="1" checked /> <label for="isshow1" style="font-weight:100">审核通过</label>
								<input name="isshow" type='radio' id="isshow0" value="0" /> <label for="isshow0" style="font-weight:100">待审核</label>
							</td>
						</tr>
						<tr>
							<td style="padding-top: 10px;font-weight: bold;font-size: 14px;">允许评论</td>
						</tr>
						<tr>
							<td style="padding-top: 10px;">
								<input name="isreview" type='radio' id="isreview1" value="1" checked /> <label for="isreview1" style="font-weight:100">允许评论</label>
								<input name="isreview" type='radio' id="isreview0" value="0" /> <label for="isreview0" style="font-weight:100">不允许评论</label>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<div class="table_list table_left">
		<div class="art-left" title="信息发布" >
			<div class="table-full">
				<table width="100%">
					<tbody>
						<tr style="position:relative;">
							<th width="80">栏目</th>
							<td style="padding-top: 12px;">
								<span class="must_red"  style="position:relative;top:-3px;left:10px;">*</span>
								<span style="position:relative;top:-3px;left:20px;"><?php echo ($catname); ?></span>
							</td>
						</tr>
						<tr>
							<th width="80">标题</th>
							<td><input type="text" class="input length_6" name="title" value="" id="title" onkeyup="strlen_verify(this, 'title_len', 80)">
							<input type="hidden" name="titlew" id="titlew" value="">
							<span class="color_pick J_color_pick"><em style="background:;" class="J_bg"></em></span>
							<img src="/Public/intendant/images/bold.png" width="10" height="10" onclick="input_font_bold()" style="cursor:hand">
							<input type="hidden" name="titlecolor" id="titlecolor" class="J_hidden_color" value="">
							<span>还可输入<b><span id="title_len">80</span></b> 个字符</span></td>
						</tr>
						<tr>
							<th width="80">关键字</th>
							<td><input type="text" class="input length_6" name="keywords" value="" id="keywords">
							<span>多关之间用空格或者“,”隔开</span></td>
						</tr>
						<tr>
							<th width="80">TAGS</th>
							<td><input type="text" class="input length_6" name="tags" value="" id="tags">
							<span>多关之间用空格或者“,”隔开</span></td>
						</tr>
						<tr>
							<th width="80">摘要</th>
							<td><textarea name="description" id="description" style="width:99%;height:46px;" onkeyup="strlen_verify(this, 'description_len', 255)"></textarea><span>还可输入<b><span id="description_len">255</span></b> 个字符</span></td>
						</tr>
						<tr>
							<th width="80">信息来源</th>
							<td><input type="text" class="input length_6" name="copyfrom" value="" id="copyfrom"></td>
						</tr>
						<tr>
							<th width="80">内容</th>
							<td ><script id="content" name="content" type="text/plain" style="width:100%;height:300px;"></script>
							<!-- 百度编辑器 -->
							<script type="text/javascript">
							var lujin = '<?php echo U("Ueditor/upload");?>';
							// window.UEDITOR_HOME_URL ='/Public/common/js/ueditor/';
							</script>
							<script type="text/javascript"  src="/Public/common/js/ueditor/ueditor.config.js"></script>
							<script type="text/javascript"  src="/Public/common/js/ueditor/ueditor.all.js"></script>
							<script type="text/javascript"  src="/Public/common/js/ueditor/lang/zh-cn/zh-cn.js"></script>
							<script type="text/javascript">
							// var ue = UE.getEditor('nyxx-add-editor'); //百度编辑器实例化
							$(function(){
						        var url='/Intendant/Ueditor/upload';
						        var ue = UE.getEditor('content',{
						            serverUrl :url,
						            UEDITOR_HOME_URL:'/Public/common/js/ueditor/',
						        });

						        ue.ready(function(){
						            ue.execCommand('serverparam', {
						                'admin_uid': '1',
						               	'admin_user': 'iteny',
						            });
						        });

						    });
							</script>
							</td>

						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<div class="btn_wrap">
        <div class="btn_wrap_pd" style="text-align: center">
          <button class="btn btn_submit mr10" id="J_ajax_export" type="submit">提交</button>
          <button class="btn btn_submit mr10" id="J_ajax_close" type="button">关闭</button>

        </div>
    </div>
</form>
<script type="text/javascript">
// var article = "<?php echo U('Content/');?>"
//添加/修改文章时，标题加粗
function input_font_bold() {
    if ($('#title').css('font-weight') == '700' || $('#title').css('font-weight') == 'bold') {
        $('#title').css('font-weight', 'normal');
        $('#titlew').val('');
    } else {
        $('#title').css('font-weight', 'bold');
        $('#titlew').val('bold');
    }
}
//输入长度提示
function strlen_verify(obj, checklen, maxlen) {
    var v = obj.value,
        charlen = 0,
        maxlen = !maxlen ? 200 : maxlen,
        curlen = maxlen,
        len = strlen(v);
    var charset = 'utf-8';
    for (var i = 0; i < v.length; i++) {
        if (v.charCodeAt(i) < 0 || v.charCodeAt(i) > 255) {
            curlen -= charset == 'utf-8' ? 2 : 1;
        }
    }
    if (curlen >= len) {
        $('#' + checklen).html(curlen - len);
    } else {
        obj.value = mb_cutstr(v, maxlen, true);
    }
}
//长度统计
function strlen(str) {
    return ($.browser.msie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
function mb_cutstr(str, maxlen, dot) {
    var len = 0;
    var ret = '';
    var dot = !dot ? '...' : '';

    maxlen = maxlen - dot.length;
    for (var i = 0; i < str.length; i++) {
        len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
        if (len > maxlen) {
            ret += dot;
            break;
        }
        ret += str.substr(i, 1);
    }
    return ret;
}
$(function(){
	$('#relat').on('click', function (e) {
		e.preventDefault();
		//添加相关文章
		layer.open({
		  type: 2,
		  area: ['700px', '530px'],
		  fix: false, //不固定
		  maxmin: true,
		  content: '<?php echo U("Content/reArticle");?>',
		});
	});
	$('#J_ajax_close').on('click', function (e) {
		e.preventDefault();
		window.close();
		return true;
	});


	//拾色器
    // var color_pick = $('.J_color_pick');
    // if (color_pick.length) {
        // Wind.use('colorPicker', function () {
            // color_pick.each(function () {
                $('.J_color_pick').colorPicker({
                    default_color: 'url("/Public/common/js/colorPicker/transparent.png")', //写死
                    callback: function (color) {
                        var em = $(this).find('em'),
                            input = $(this).next('.J_hidden_color');

                        em.css('background', color);
                        input.val(color.length === 7 ? color : '');
                    }
                });
            // });
        // });
    // }
	jQuery.validator.addMethod("chinaese", function(value, element) {
	  var chinaese = /^[\u4e00-\u9fa5]+$/;
	  return this.optional(element) || (chinaese.test(value));
	  }, "只能输入中文");
	$('form[name=addArticle]').validate({
		errorElement : 'span',
		validClass: "success",	//非常重要
		success : function (label) {
			label.addClass('success');
		},

        rules : {
                title : {
                    required : true,
                    // remote : {
                    //  url : checkAddCate,
                    //  type : 'post',
                    //  dataType : 'json',
                    //  data : {
                    //    title : function(){
                    //      return $('#title').val();
                    //    }
                    //  }
                    // }
                },

            },
        messages : {
                title : {
                    required : "请输入栏目名称",
                    // remote : '栏目名称已存在'
                },

            },
            submitHandler: function(form)
            {
            	if(!UE.getEditor('content').hasContents()){
            		ITENY.alert('提示','内容不能为空',1,'3000');
            		UE.getEditor('content').focus();
            		return false;
            	}
            	if($(this).attr("disabledSubmit")){
			        $(this).text('请勿重复提交...').prop('disabled', true).addClass('disabled');
			        return false;
			    }
				$(this).attr("disabledSubmit",true);
            	var param = $('form[name=addArticle]').serialize();
            	$.ajax({
					url: $('form[name=addArticle]').attr('action'),
					dataType:'json',
					type:'POST',
					data:param,
					success: function(data) {
						if (data=='-20') {
							layer.confirm('文章添加成功', {
							  	btn: ['继续添加？','关闭'] //按钮
							}, function(){
							  	ITENY.reloadPage(window);
								return true;
							}, function(){
							  	window.close();
								return true;
							});
						}
						else if(data=='-2')
						{
							ITENY.alert('提示','标题不能为空',1,'3000');
							$(this).text('添加').removeProp('disabled').removeClass('disabled');
							$(this).attr("disabledSubmit",'');
						}
						else if(data=='-4')
						{
							ITENY.alert('提示','标题已存在',1,'3000');
							$(this).text('添加').removeProp('disabled').removeClass('disabled');
							$(this).attr("disabledSubmit",'');
						}
						else {
							ITENY.alert('提示','未知错误，请联系管理员！',1,'3000');
							$(this).text('添加').removeProp('disabled').removeClass('disabled');
							$(this).attr("disabledSubmit",'');
						}
					}
				});

            }

	});
});
</script>

</body>
</html>